import request from './request'
import qs from 'qs'
// markdown发布
export function post(topic) {
    return request({
        url: '/post/markdown/release',
        method: 'post',
        data: {
            userId: topic.userId,
            postTitle: topic.postTitle,
            postContents: topic.postContents
        }
    })
}

//发布评论
export function postComment(content, id, userId) {
    return request({
        url: '/comment',
        method: 'post',
        data: {
            momentId: id,
            content,

        }

    })
}
//发布回复评论，回复首层的评论
export function postReplyComment(content, momentId, commentId) {
    return request({
        url: '/comment/reply',
        method: 'post',
        data: {
            content, momentId, commentId
        }

    })
}
//发布回复评论，回复其他层的评论
export function postReplyOthersComment(content, momentId, commentId, reply_comment_id, target_user_name) {
    return request({
        url: '/comment/replycomment',
        method: 'post',
        data: {
            content, momentId, commentId, reply_comment_id, target_user_name
        }

    })
}
//获取标签列表
export function getTagList() {
    return request({
        url: '/label',
        method: 'get',
        params: {
            offset: 0,
            limit: 10
        }

    })
}

//普通发布
export function postTopic(topic) {
    return request({
        url: '/moment',
        method: 'post',
        data: {
            userId: topic.userId,
            content: topic.postContents,
            images: topic.imageUriList,
            labels: topic.topicNameList,
            plateId: topic.plateId
        }

    })
}
//删除照片墙的照片
export function removeImg(imgUrl) {
    return request({
        url: `/post/edit/resource-delete/${imgUrl}`,
        method: 'get',
    })
}

//获取关注列表
export function getFocusList() {
    return request({
        url: '/user/myFollowList',
        method: 'get',
    })
}

//关注
export function addfocus(targetuserId, relationFlag) {
    let data = qs.stringify({
        targetuserId: targetuserId,
        relationFlag: relationFlag
    })
    return request({
        url: '/user/setRelation',
        method: 'post',
        data: data
    })
}

//取消关注
export function cancelfocus(targetuserId) {
    let data = qs.stringify({
        targetuserId: targetuserId
    })
    return request({
        url: '/user/deleteRelation',
        method: 'post',
        data: data
    })
}
//获取用户最近浏览记录
export function getrecentlyviewed(userId) {
    return request({
        url: '/user/getMyPost',
        method: 'get',
        params: {
            userId
        }
    })
}